//
//  UIBarButtonItem+BSBButtonItem.m
//  Baisebudejie
//
//  Created by apple on 16/3/14.
//  Copyright © 2016年 youminuo. All rights reserved.
//

#import "UIBarButtonItem+BSBButtonItem.h"

@implementation UIBarButtonItem (BSBButtonItem)
+ (instancetype)itemWithimage:(NSString *)image hightImage:(NSString *)hightimage target:(UIViewController *)target action:(SEL)sel
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setBackgroundImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    [btn setBackgroundImage:[UIImage imageNamed:hightimage] forState:UIControlStateHighlighted];
    CGRect frame = btn.frame;
    frame.size = btn.currentBackgroundImage.size;
    btn.frame = frame;
    btn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
//    btn.contentEdgeInsets = UIEdgeInsetsMake(0, -5, 0, 0);
    [btn addTarget:target action:sel forControlEvents:UIControlEventTouchUpInside];
    return [[UIBarButtonItem alloc] initWithCustomView:btn];
}
@end
